package com.kdd.campus.common.exception;

import com.kdd.campus.common.entity.CommonResult;
import com.kdd.campus.common.entity.HttpCode;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Auther: fcp
 * @Date: 2020/5/5 15:50
 * @Description:
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(MyException.class)
    public CommonResult handlerMyException(MyException exception){
        return CommonResult.failed(HttpCode.fromDescribe(exception.getMessage()));
    }
}
